<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="button" value="返回按钮" onclick="goBack()">
<input type="button" value="随机跳转" onclick="goRandom()">
<script>
    var stateObj = { foo: 'bar' };
    // history.pushState(stateObj, 'page 2', '2.html');
    // console.log(history.state); // {foo: "bar"}
    function goBack() {
        window.history.back()
    }

    function goRandom() {
        window.history.go(0)

    }
</script>
</body>
</html>